<?php

namespace app\common\model;

use think\Model;

class Addons extends Model
{
    protected $name = 'addons';
    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'createtime';
    public function setRequireAttr($value)
    {
        if(!empty($value)){
            if(is_array($value)){
                $value = explode(',',$value);
            }
        }
        return $value;
    }
    public function getRequireAttr($value)
    {
        if(!empty($value)){
            if(is_string($value)){
                $value = explode(',',$value);
            }
        }else{
            $value = [];
        }
        return $value;
    }
    public function setEventAttr($value)
    {
        if(!empty($value)){
            if(is_array($value)){
                $value = json_encode($value,JSON_UNESCAPED_SLASHES|JSON_PARTIAL_OUTPUT_ON_ERROR);
            }
        }
        return $value;
    }
    public function getEventAttr($value)
    {
        if(!empty($value)){
            if(is_string($value)){
                $value = json_decode($value,true);
            }
        }else{
            $value = [];
        }
        return $value;
    }
}